namespace WiseLink.RDS.Web
{
    using System;
    using System.Web.Mvc;
    using Telerik.Web.Mvc;
    using Models;
    using System.Data.Linq;
    using System.Linq;
    using System.Collections.Generic;
    using WiseLink.RDS.Model;

    public partial class DiagnosticController : Controller
    {
        DiagnosticRepository diagnosticRep;
        
        
        [GridAction]
        public ActionResult FirstLook()
        {
            return View(new GridModel<DiagnosticModel>
            {
                Data = diagnosticRep.GetDiagnosticInfo(false)
            });

        }


        [GridAction]
        public JsonResult GetUnConfirmedFaultVehicle(int? VehicleID)
        {
            if (VehicleID == null)
                return Json("");
            return Json(diagnosticRep.GetUnconfirmedFaultByVehicle(VehicleID));

        }

        [GridAction]
        public JsonResult GetMaintenanceByVehicle(int? VehicleID)
        {
            if (VehicleID == null) return Json("");
            return Json(diagnosticRep.GetMaintenanceByVehicle(VehicleID));

        }

        [GridAction]
        public JsonResult GetPhoneContactHistoryByVehicle(int? VehicleID)
        {
            if (VehicleID == null) return Json("");
            return Json(diagnosticRep.GetContactHistoryByVehicle(VehicleID));

        }
        //SimpleCustomer for the customers dropdown
        [HttpPost]
        public ActionResult GetContactResultList()
        {

            return new JsonResult
            {
                Data = diagnosticRep.GetContactResult()
            };

        }
        public ActionResult SecondLook()
        {

            return View();
        }
        public DiagnosticController()
        {
            diagnosticRep = new DiagnosticRepository();

        }

        [GridAction]
        public JsonResult AddContactHistoryForVehicle(int vehicleID,string contactResult,string contactRemark)
        {
            
            diagnosticRep.AddContactHistoryForVehicle(vehicleID, contactResult, contactRemark);
            return Json("succeed");

        }
    }
}